<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;

class CheckLogin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        Log::info('Showing user profile for user: '.$request);
        if (Session::get('admin')==null) {
            return redirect('/admin/login');
        }
        return $next($request);
    }
    public function terminate($request, $response)
    {
        // Store the session data...
    }
}
